﻿using StructureMap;
using StructureMap.Attributes;
using Wayloop.Blog.Core.Services;
using Wayloop.Blog.Core.Services.Impl;


namespace Wayloop.Blog.DependencyResolution
{
    internal static class DependencyRegistry
    {
        public static void Initialize()
        {
            ObjectFactory.Initialize(factory => {
                factory.Scan(x => {
                    x.Assembly("Wayloop.Blog.Core");
                    x.Assembly("Wayloop.Blog.DataAccess");
                    x.WithDefaultConventions();
                });

                //
                // Defaults
                // --------
                factory.ForRequestedType<IConfigurationService>().TheDefaultIsConcreteType<XmlConfigurationService>().CacheBy(InstanceScope.Hybrid);
                factory.ForRequestedType<INotificationService>().TheDefaultIsConcreteType<EmailNotificationService>();

                //
                // Property Injection
                // ------------------
                factory.FillAllPropertiesOfType<IConfigurationService>();
                factory.FillAllPropertiesOfType<INotificationService>();
            });
        }
    }
}